<include file="public@header"/>

</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('Score/index')}">所有学期</a></li>
        <li><a href="{:url('Score/add')}">添加学期</a></li>
    </ul>
        <form class="well form-inline margin-top-20" method="get"  action="{:url('Score/index')}">
            学生姓名：
            <input type="text" class="form-control" value="{$Request.param.name}" name="name" style="width: 150px;"  placeholder="请输入学生姓名">
            学期：
            <select name="term_id" class="form-control">
                <option value="">请选择学期</option>
                <foreach name="term" item="vo">
                    <option value="{$vo.id}"<if $vo.id == $Request.param.term_id> selected </if>>{$vo.term_name}</option>
                </foreach>
            </select>
            科目名称：
            <select name="subject_id" class="form-control">
                <option value="">请选择科目</option>
                <foreach name="subject" item="vo">
                    <option value="{$vo.id}"<if $vo.id == $Request.param.subject_id> selected </if>>{$vo.course_name}</option>
                </foreach>
            </select>
            <input type="submit" class="btn btn-primary" value="搜索" />
            <a class="btn btn-danger" href="{:url('Score/index')}">清空</a>
        </form>
    <form  method="post" class="margin-top-20" action="{:url('Score/delAll')}">
        <button class="btn btn-xs btn-danger" onclick="delCheck()">批量删除</button>
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th>
                    <input type="checkbox" onclick="checkAll(this)">
                </th>
                <th>ID</th>
                <th>学生姓名</th>
                <th>所在学期</th>
                <th>所学科目</th>
                <th>科目成绩</th>

                <th>{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>
            <foreach name="data" item="vo">
                <tr>
                    <td>
                    <input type="checkbox" name="ids[]" value="{$vo.id}" >
                    </td>
                    <td>{$vo.id}</td>
                    <td>
                            {$vo.student.name}
                    </td>
                    <td>{$vo.term.term_name}</td>
                    <td>{$vo.course.course_name}</td>
                    <td>
                        <if $vo.score < 60>
                            <span style="color:red">{$vo.score}</span>
                            <else>
                                {$vo.score}
                            </else>
                        </if>
                    </td>

                    <td>
                        <a class="btn btn-xs btn-primary" href="{:url('Score/add')}">添加</a>
                        <a class="btn btn-xs btn-success"  href="{:url('Score/edit')}?id={$vo.id}">{:lang('EDIT')}</a>
                        <a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('Score/delete')}?id={$vo.id}">{:lang('DELETE')}</a>
                    </td>
                </tr>
            </foreach>
            </tbody>

        </table>
        <div class="pagination" style = "margin-left:500px">
            <div class="pagination" >
                {$page}
            </div>
            <div class="">
                共 {$data->total()} 条数据，当前第 {$data->currentPage()} 页，共 {$data->lastPage()} 页
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    //全选
    function checkAll(e) {
        var item = document.getElementsByName('ids[]');
        for (var i = 0; i < item.length; i++)
        {
            item[i].checked = e.checked;
        }
    }
    //全选删除
    function delCheck() {
        var isCheck = false;
        var item = document.getElementsByName('ids[]');
        for (var i = 0; i < item.length; i++)
        {
            if (item[i].checked)
            {
                isCheck = true;
            }
        }
        if (isCheck)
        {
            return confirm('确定删除吗？');
        } else {
            alert('请至少选择一项！');
            // layer.msg('请至少选择一项');
            return false;
        }
    }


</script>
</body>
</html>